//
//  HeadResources.swift
//  LoveFreshBeen
//
//  Created by Gao on 17/2/9.
//  Copyright © 2017年 Odm. All rights reserved.
//

import UIKit

class Activities: NSObject {
    var id: String?
    var name: String?
    var img: String?
    var topimg: String?
    var jptype: String?
    var trackid: String?
    var mimg: String?
    var customURL: String?
}

class HeadData: NSObject {
    var focus: [Activities]?
    var icons: [Activities]?
    var activities: [Activities]?
    
    // 返回容器类中的所需要存放的数据类型 (以 Class 或 Class Name 的形式)。
    class func modelContainerPropertyGenericClass() -> [AnyHashable: Any] {
        return ["focus": Activities.self, "icons": Activities.self, "activities": Activities.self]
    }

}

class HeadResources: NSObject {

    var msg: String?
    var reqid: String?
    var data: HeadData?
    
    // 返回容器类中的所需要存放的数据类型 (以 Class 或 Class Name 的形式)。
    class func modelContainerPropertyGenericClass() -> [AnyHashable: Any] {
        return ["data": HeadData.self]
    }
    
    class func loadHomeHeadData(_ completion:(_ data: HeadResources?, _ error: NSError?) -> Void) {
        
        guard let path = Bundle.main.path(forResource: "首页焦点按钮", ofType: nil) else{
            return
        }
        
        let url = URL(fileURLWithPath: path)
        
        guard let jsonString = try? String(contentsOf: url) else{
            return
        }
        
        let headResources = HeadResources.yy_model(withJSON: jsonString)
        
        if headResources != nil {
            completion(headResources, nil)
        }
    }
}


